package cn.lili.modules.payment.entity.dos;

import cn.lili.common.security.enums.SceneEnums;
import cn.lili.modules.member.entity.dos.User;
import cn.lili.modules.store.entity.dos.Store;
import cn.lili.modules.urbansubstation.entity.dos.UrbanSubstation;
import cn.lili.mybatis.model.BaseStandardEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Min;
import java.io.Serial;


/**
 * 用户预存款
 *
 * @author pikachu
 * @since 2020-02-25 14:10:16
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("li_user_wallet")
@ApiModel(value = "用户预存款")
public class UserWallet extends BaseStandardEntity {

    @Serial
    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "用户ID")
    private String userId;

    @ApiModelProperty(value = "昵称")
    private String nickName;

    @ApiModelProperty(value = "用户名（用作模糊匹配场景）")
    private String userName;

    @Min(message = "必须为数字", value = 0)
    @ApiModelProperty(value = "积分数量")
    private Double points;

    @Min(message = "必须为数字", value = 0)
    @ApiModelProperty(value = "积分总量（用于经验，提供用户等级等支持）")
    private Double totalPoints;

    @ApiModelProperty(value = "用户预存款")
    private Double balance;

    @ApiModelProperty(value = "冻结金额")
    private Double frozenBalance;

    @ApiModelProperty(value = "钱包密码")
    private String walletPassword;

    @ApiModelProperty(value = "场景")
    private String scene;

    @Min(message = "必须为数字", value = 0)
    @ApiModelProperty(value = "F分数量")
    private Double fmoney;

    @Min(message = "必须为数字", value = 0)
    @ApiModelProperty(value = "F分总量")
    private Double totalFmoney;

    public UserWallet(Store store) {
        this.setUserId(store.getId());
        this.setNickName(store.getStoreName());
        this.setUserName(store.getStoreName());
        this.setPoints(0D);
        this.setTotalPoints(0D);
        this.setBalance(0D);
        this.setFrozenBalance(0D);
        this.setFmoney(0D);
        this.setTotalFmoney(0D);
        this.setScene(SceneEnums.STORE.name());
    }

    public UserWallet(User user) {
        this.setUserId(user.getId());
        this.setNickName(user.getNickName());
        this.setUserName(user.getUsername());
        this.setPoints(0D);
        this.setTotalPoints(0D);
        this.setBalance(0D);
        this.setFrozenBalance(0D);
        this.setFmoney(0D);
        this.setTotalFmoney(0D);
        this.setScene(SceneEnums.MEMBER.name());
    }

    public UserWallet(UrbanSubstation urbanSubstation) {
        this.setUserId(urbanSubstation.getId());
        this.setNickName(urbanSubstation.getUrbanName());
        this.setUserName(urbanSubstation.getUrbanName());
        this.setPoints(0D);
        this.setTotalPoints(0D);
        this.setBalance(0D);
        this.setFrozenBalance(0D);
        this.setFmoney(0D);
        this.setTotalFmoney(0D);
        this.setScene(SceneEnums.URBAN_SUBSTATION.name());
    }
}
